import logging
from redis import StrictRedis


class Config(object):
    """项目的配置"""

    SECRET_KEY = 'JQe0QEc0F8paArJY+9kzkm3FbAsqvSsziOTeMvqE7Dh5HA5lG3EZ+lT1mw2UAYwl'
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/information27'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    #  设置SQLALchemy开启自动commit功能
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    #  Session保存配置
    SESSION_TYPE = 'redis'
    #  Session签名
    SESSION_USE_SIGNER = True
    #  Session指定到保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    #  设置是否过期
    SESSION_PERMANENT = False
    #  设置过期时间 2天
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    #  设置日志的记录等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    DEBUG = True


class ProductionConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING


config = {
    'development':DevelopmentConfig,
    'production':ProductionConfig
}